package oop.movie;

import java.util.Scanner;

public class movieSelect {
    private movie[]movies;
    public  movieSelect(){

    }
    public movieSelect(movie[] movies) {
        this.movies=movies;
    }

    public void start(){
        Scanner scanner=new Scanner(System.in);
        looper:
        while (true){
            System.out.println("----电影信息系统----");

            System.out.println("1.查询所有电影信息");
            System.out.println("2.按id查询电影信息");
            System.out.println("3.退出");
            System.out.println("请输入选择：");
            int select=scanner.nextInt();
            switch (select){
                case 1:
                    getAllMovie(movies);
                    break;
                case 2:
                    getMvoie();
                    break;
                case 3:
                    System.out.println("退出中。。。");
                    break looper;
            }
        }
    }
    public void getAllMovie(movie []movies){
        for (int i = 0; i <movies.length ; i++) {
            String name=movies[i].getName();
            double score=movies[i].getScore();
            System.out.println("电影名:"+name+"   "+"得分:"+score);
        }
    }
    public void getMvoie(){
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入查找的编号：");
        int id=scanner.nextInt();
        for (int i = 0; i <movies.length ; i++) {
            if (id==movies[i].getId()){
                System.out.println("电影名:"+movies[i].getName()+"---"+"得分:"+movies[i].getScore());
                System.out.println( "上映地区:"+movies[i].getArea()+"---"+"上映时间:"+movies[i].getTime()
                        +"---"+movies[i].getType());
                System.out.println("导演:"+movies[i].getDirector()+"---" +"主演:"+movies[i].getMajor());
                break;
            }else {
                System.out.println("查询失败");
            }
        }

    }

}
